package com.example.mq.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xyh
 * @description
 * @date 2021/3/31 15:25
 */
@Configuration
public class RabbitMQTopicConfig {
    public static final String first_queue = "qm_TOPIC.first";
    public static final String sencond_queue = "qm_TOPIC.second";

    public static final String first_key = "top.first";
    public static final String sencond_key = "top.#";
    public static final String topicExchange = "topicExchange";

    @Bean
    public Queue firstQueue(){

        return new Queue(first_queue);
    }

    @Bean
    public Queue secondQueue(){

        return new Queue(first_queue);
    }

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("topicExchange");
    }

    @Bean
    public Binding bindingExhcange(){

        return BindingBuilder.bind(firstQueue()).to(topicExchange()).with(first_key);
    }

    @Bean
    public Binding bindingExhcange2(){

        return BindingBuilder.bind(secondQueue()).to(topicExchange()).with(sencond_key);
    }


}
